package com.example.partner.adapter.user;

import android.util.Log;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.partner.fragment.CommonFragment;
import com.example.partner.fragment.MatchFragment;
import com.example.partner.fragment.NearFragment;

public class UserViewPagerAdapter extends FragmentStateAdapter {

    public UserViewPagerAdapter(@NonNull FragmentActivity fragmentActivity) {
        super(fragmentActivity);
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        Log.d("ViewPager", "Creating fragment at position: " + position);

        // 根据位置返回对应的Fragment
        switch (position) {
            case 0:
                return new CommonFragment();
            case 1:
                return new MatchFragment();
           case 2:
                return new NearFragment();
        }
        return null;
    }

    @Override
    public int getItemCount() {
        return 3; // 标签总数
    }
}
